﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.CompanyEditViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Sửa thông tin doanh nghiệp
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%if (ViewData["MessageInfo"] == null)
  { %>
<% using (Html.BeginForm("Edit", "Company", FormMethod.Post, new { id = "adminForm", name = "adminForm", enctype = "multipart/form-data" }))
   {%>
    <%= Html.ValidationSummary(true)%>
    
    <fieldset>
        <legend>Chi tiết chuyên mục</legend>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Thông tin chung</a></li>
                <li><a href="#tabs-2">Giới thiệu</a></li>
                <li><a href="#tabs-3">Lĩnh vực hoạt động</a></li>
            </ul>
            <div id="tabs-1">
                <table class="admintable">
                    <tbody>
                        
                        <tr>
                            <td class="key">Tên doanh nghiệp  (<font color="red">*</font>)
                            </td>
                            <td>
                                <%= Html.TextBoxFor(model => model.Company.Name, new { @class = "required", style="width:400px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Tên vắn tắt</td>
                            <td>
                                <%= Html.TextBoxFor(model => model.Company.ShortName) %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Địa chỉ</td>
                            <td><%=Html.TextBoxFor(model => model.Company.Address) %></td>
                        </tr>
                        <tr>
                            <td class="key">Logo</td>
                            <td>
                   	            <div>
				                    <div class="div_img">
	                                     <img class="represent" alt="<%=Model.Company.Name%>" src="<%= string.Format("{0}{1}", Model.ImageRootUrl,""+Model.Company.ID+"_"+ Model.Company.ImagePath) %>" />
	                                     <input type="file" name="CompanyFile" id="CompanyFile"/>
	                                </div>
				                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tỉnh thành (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.DropDownListFor(m => m.Company.CityID, Model.ListCity, "-- Chọn tỉnh thành --", new {@class="required" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Quận/Huyện (<font color="red">*</font>)
                            </td>
                            <td>
                                
                                <%=Html.DropDownListFor(m => m.Company.DistrictID, Model.ListDistrict, "-- Chọn quận huyện --", new { @class="required"})%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Số điện thoại</td>
                            <td><%=Html.TextBoxFor(model => model.Company.Phone) %></td>
                        </tr>
                        <tr>
                            <td class="key">Fax</td>
                            <td><%=Html.TextBoxFor(model => model.Company.Fax) %></td>
                        </tr>
                        <tr>
                            <td class="key">Website</td>
                            <td><%=Html.TextBoxFor(model =>model.Company.Website) %></td>
                        </tr>
                        <tr>
                            <td class="key">
                                Yahoo ID
                            </td>
                            <td>
                                <%= Html.TextBoxFor(model => model.Company.YahooID, new {style="width:500px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Skype ID
                            </td>
                            <td>
                                <%= Html.TextBoxFor(model => model.Company.SkypeID, new {style="width:500px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Độ ưu tiên (<font color="red">*</font>)
                            </td>
                            <td>
                                <%= Html.TextBoxFor(m => m.Company.Priority, new { @class = "required", style = "width:30px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Trạng thái kích hoạt (<font color="red">*</font>)</td>
                            <td><%=Html.RadioButton("Company.ActiveYN", true, Model.Company.ActiveYN == true ? new { @checked = "checked" } : null)%> Kích hoạt
                            <%=Html.RadioButton("Company.ActiveYN", false, Model.Company.ActiveYN == false ? new { @checked = "checked" } : null)%> Không kích hoạt</td>
                        </tr>
                        <tr>
                            <td class="key">Trạng thái "HOT"</td>
                            <td><%=Html.RadioButton("Company.HotYN", true, Model.Company.HotYN == true ? new { @checked = "checked" } : null)%> "HOT"
                            <%=Html.RadioButton("Company.HotYN", false, Model.Company.HotYN == false ? new { @checked = "checked" } : null)%> Không "HOT"</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div id="tabs-2">
                <div>
                    <%=Html.TextAreaFor(model => model.Company.Description , new { style = "width: 900px; height: 500px;" })%>
                    <div class="clear"></div>
                </div>
                <div>
                     <%= Html.TextAreaFor(m => m.Company.Development, new { rows = "30", cols = 20, style = "width:760px" })%>
                     <div class="clear"></div>
                </div>
                <div>
                    <%= Html.TextAreaFor(m => m.Company.OrgStructure, new { rows = "30", cols = 20, style = "width:760px" })%>
                    <div class="clear"></div>
                </div>
            </div>
            <div id="tabs-3">
                <div>
                    <ul style="margin:0;padding:0;list-style-type:none;">
                        <% foreach (var item in Model.CompanyTypes)
                           {
                               var testChecked="";
                            foreach(var itemCompanyTypeMap in Model.CompanyTypeMaps)
                            {
                                if(itemCompanyTypeMap.CompanyTypeID == item.ID) testChecked="checked";      
                            }  
                                    
                        %>
                           <li> 
                                <input type="checkbox" id="CompanyType.<%=item.ID %>" name="CompanyType.<%=item.ID %>" <%=testChecked %> />
                                <%=item.Name%>
                           </li>
                        <%} %>
                    </ul>
                    <div class="clear"></div>
                </div>
            </div>
            <div style="display: block; padding: 10px; margin-top: 5px">
            <input type="submit" id="btnSave" value="Lưu" /></div>
        </div>
		     <script type="text/javascript">
		         $(document).ready(function() {
		             $(function() {
		                 $("#tabs").tabs();
		             });

		             $("#adminForm").validate();
		             $.datepicker.setDefaults($.datepicker.regional['vi']);
		             $(".datepicker").datepicker({
		                 yearRange: '-30',
		                 dateFormat: "dd/mm/yy",
		                 changeMonth: true,
		                 changeYear: true
		             });
                    $("#Company_CityID").unbind("change").change(function() {
                            var val = $("#Company_CityID").val();
                                    if (val == "" || val == '' || val == undefined)
                                        return false;
                                    AjaxChange("#Company_CityID", "#Company_DistrictID", "/AjaxData/LoadDistrictByCity/");
                     });       
		         });
    </script>
   </fieldset>
    <% }
  } %>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
        });
        tinyMCE.init({
            mode: "exact",
            elements: "Company_Description",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
    </script>
    
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
    <%= Html.Toolbar("Quay về", "/Company/Index/" , "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Sửa thông tin doanh nghiệp
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%> 
</asp:Content>
